
$(document).ready(function() {
	initTable();
	
	$('#search').on('click',function(){
		initTable();
	});
});

var table = new Table();
var initTable =function(){
	//筛选条件
	var name = $('#commodityName').val()
	var sql ='';
	if(name!=null&& name!=''){
		sql = '?commodityName='+name;
	}
	//表格加载的字段
    var cloumns = [
		    {'data': 'id','render': function (data) {return '<input type="checkbox" data-id="' + data + '" name="">';}},
		    {'data': 'picture','render': function (data) {return '<img style="max-width: 40px; max-height: 40px;"  src= "'+basePath+'/'+data+'" />';}},
		    {'data': 'commodity_name'},
		    {'data': 'start_date_time'},
		    {'data': 'end_date_time'},
		    {'data': 'start_price'},
		    {'data': 'add_price'},
		    {'data': 'deal_price'},
		    {'data': 'recovery_proportion'},
		    {'data': 'create_name'},
		    {'data': 'update_date'},
		    {'data': 'id','render':function(data){return table.delBtn(data)+table.editBtn('编辑商品',basePath+"/com/toEditCommodity?id="+data,'2');}}
		  ];
	//设置URL和加载的字段
    table.setting(basePath+"/com/getCommodityList"+sql,basePath+"/com/delCommodity",cloumns);
	//调用表格分页
    table.tablePage();
}


